Skip to content

Conversation

@dgarske
Copy link
Contributor

@dgarske dgarske commented Dec 31, 2025

Add NXP S32K1xx Support

This PR adds full wolfBoot support for the NXP S32K1xx automotive microcontroller family (S32K142, S32K144, S32K146, S32K148).

Summary

Adds a complete bare-metal HAL implementation for the S32K1xx Cortex-M4F family with sector-swap firmware update capability. Tested on S32K142EVB with successful firmware updates.

Features

HAL Implementation (hal/s32k1xx.c, hal/s32k1xx.h):

  • Flash programming using FTFC controller (phrase-level 8-byte writes)
  • LPUART1 debug output at 115200 baud
  • Clock configuration using FIRC (48 MHz internal RC oscillator)
  • Watchdog management (disable during boot, optional enable for production)
  • Flash Configuration Field (FCF) for security settings

Test Application (test-app/app_s32k1xx.c):

  • Interactive console with commands: status, trigger, success, reboot, help
  • LED indicators: Green LED for v1, Blue LED for v2+
  • XMODEM firmware update support
  • Partition and keystore information display

Configuration Files:

  • config/examples/nxp-s32k142.config - 256KB Flash, 32KB SRAM, 2KB sectors
  • config/examples/nxp-s32k144.config - 512KB Flash, 64KB SRAM, 4KB sectors
  • config/examples/nxp-s32k146.config - 1MB Flash, 128KB SRAM, 4KB sectors
  • config/examples/nxp-s32k148.config - 2MB Flash, 256KB SRAM, 4KB sectors

Tooling:

  • tools/scripts/nxp-s32k142-flash.sh - Automated build, sign, and flash script using J-Link

Memory Layout (S32K142)

Region Address Range Size
Bootloader 0x00000000 - 0x0000BFFF 48 KB
Boot Partition 0x0000C000 - 0x00024FFF 100 KB
Update Partition 0x00025000 - 0x0003DFFF 100 KB
Swap Sector 0x0003E000 - 0x0003E7FF 2 KB

Important Configuration Requirements

  • NVM_FLASH_WRITEONCE=1 - Required because S32K1xx flash cannot be reprogrammed without erase
  • RAM_CODE=1 - Required because flash cannot be read while being programmed

Build & Test

# Build wolfBoot
cp config/examples/nxp-s32k142.config .config
make clean && make

# Build test app
make test-app/image.bin

# Sign images
./tools/keytools/sign --ecc256 --sha256 test-app/image.bin wolfboot_signing_private_key.der 1
./tools/keytools/sign --ecc256 --sha256 test-app/image.bin wolfboot_signing_private_key.der 2

Files Changed

  • New files: hal/s32k1xx.c, hal/s32k1xx.h, hal/s32k1xx.ld, test-app/app_s32k1xx.c, test-app/ARM-s32k1xx.ld
  • Config files: 4 new example configurations for S32K142/144/146/148
  • CI: Added build tests for all S32K1xx variants
  • Documentation: Added comprehensive S32K1xx section to docs/Targets.md

Testing

Verified on S32K142EVB:

  • wolfBoot boots successfully and validates firmware signature
  • Firmware update via sector swap completes successfully
  • Test application marks update as successful
  • Version rollback works correctly

@dgarske dgarske self-assigned this Dec 31, 2025
@dgarske dgarske closed this Jan 5, 2026
@dgarske dgarske reopened this Jan 5, 2026
- HAL: Flash (FTFC), UART (LPUART1), Clock (FIRC 48MHz), Watchdog
- Requires NVM_FLASH_WRITEONCE=1 and RAM_CODE=1 for proper operation
- Test app with interactive console: status, trigger, success, reboot
- LED indicators: Green (v1), Blue (v2+)
- Flash automation script: tools/scripts/nxp-s32k142-flash.sh
- Tested on S32K142EVB with sector swap update

Supported variants: S32K142 (256KB), S32K144 (512KB), S32K146 (1MB), S32K148 (2MB)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants